import request from '@/utils/request' 
import type {AttrInfoModel,AttrValueModel } from './model/attrModel'
import type { categoryIdsModel } from './model/categorySelectorModel'

// 使用枚举存储接口地址
enum Api {
    getAttrListApi = '/admin/product/attrInfoList',
    saveAttrApi = '/admin/product/saveAttrInfo',
    deleteAttrApi = '/admin/product/deleteAttr'
}

// 根据一二三级导航ID 来获取属性列表 
export const reqGetAttrListDataByCategory3Id = ({category1Id,category2Id,category3Id}:categoryIdsModel)=>{
    return request.get<any,AttrValueModel>(`${Api.getAttrListApi}/${category1Id}/${category2Id}/${category3Id}`)
}

// 添加或更新属性
export const reqAddOrUpdateAttrInfo = (attrInfo:AttrInfoModel)=>{
    return request.post(Api.saveAttrApi,attrInfo)
}

// 删除
export const reqDeleteOneAttr = (attrId:number) =>{
    return request.delete(Api.deleteAttrApi + `/${attrId}`)
}